<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
class Teacher extends  Base
{
    public function initialize(){
        parent::initialize();
    }

    public function info($input)
    {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->tinfo($input);
          return $this->print_result($res);
    }
    public function card($input)
    {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->teacherInfo($input);
          return $this->print_result($res);
    }
    public function ajaxList(){
        $input = $this->request->param(false);
        $page_limit      = isset($input['page_size'])?$input['page_size']:10;
        $page_start      = isset($input['page'])?$input['page']:0;
        $p = 1;
        if ($page_start > 0) {
            $p = ceil($page_start / ($page_limit - 1));
        }
        $sid = isset($input['sid'])?$input['sid']:0;
        if (!$sid) {
          $this->return_data['Msg'] = "缺少必填信息";
          return $this->print_result($this->return_data);
        }
        $store= Db::name('store')->where([['id','=',$sid]])->find();
        if (!$store) {
          $this->return_data['Msg'] = "无此门店";
          return $this->print_result($this->return_data);
        }
        $where = [];
        $where[] = ['sid','=',$sid];
        $where[] = ['status','=',1];
        $field = '*';
        $count=Db::name('teacher')->where($where)->count();
        $list  = Db::name('teacher')
              ->field($field)
              ->where($where)
              ->order('ordernum asc,id desc')
              ->page($page_start, $page_limit)->select();
        foreach($list as $k=>$v){
          $list[$k]['cover'] = get_basecover_img($v['avatar']);
        }

        $this->return_data['Msg']='OK';
        $this->return_data['Code']=0;
        $this->return_data['Data']=['teacher'=>$list];
        return $this->print_result($this->return_data);
   }

   // 课时日历
   public function calendar($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->calendar($input);
          return $this->print_result($res);
   }

   // 课程列表
   public function dayCourse($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->dayCourse($input);
          return $this->print_result($res);
   }

   // 课程学生列表
   public function classStudent($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->classStudent($input);
          return $this->print_result($res);
   }


   // 课后点评
   public function comment($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->comment($input);
          return $this->print_result($res);
   }


   // 签到
   public function studentSign($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->studentSign($input);
          return $this->print_result($res);
   }


   // 课时备注
   public function classtimeRemark($input)
   {
          $teacher = Controller('Teacher', 'logic');
          $res = $teacher->classtimeRemark($input);
          return $this->print_result($res);
   }

   // 请假列表
   public function  askForLeaveList($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->askForLeaveList($input);
          return $this->print_result($res);
   }

   // 请假详情
   public function  askForLeaveInfo($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->askForLeaveInfo($input);
          return $this->print_result($res);
   }

   // 请假审核
   public function  replyForLeave($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->replyForLeave($input);
          return $this->print_result($res);
   }

   // 补课申请列表
   public function  makeUpLessonsList($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->makeUpLessonsList($input);
          return $this->print_result($res);
   }

   // 补课申请详情
   public function  makeUpLessonsInfo($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->makeUpLessonsInfo($input);
          return $this->print_result($res);
   }

   // 补课审核
   public function  replyMakeUpLessons($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->replyMakeUpLessons($input);
          return $this->print_result($res);
   }

   // 课件板块
   public function  coursewareCourse($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->coursewareCourse($input);
          return $this->print_result($res);
   }

   // 课件列表
   public function  coursewareList($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->coursewareList($input);
          return $this->print_result($res);
   }

   // 课件详情
   public function  coursewareInfo($input)
   {
          $teacher = Controller('teacher', 'logic');
          $res = $teacher->coursewareInfo($input);
          return $this->print_result($res);
   }

   // 课件详情
   // public function  coursewareInfoByTopic($input)
   // {
   //        $teacher = Controller('teacher', 'logic');
   //        $res = $teacher->coursewareInfoByTopic($input);
   //        return $this->print_result($res);
   // }

}
